/*
 * @Author: january.cjy 
 * @Date: 2021-09-27 19:18:39 
 * @Last Modified by: january.cjy
 * @Last Modified time: 2021-09-27 19:50:41
 */
#include <CmgPPCallbacks.h>

namespace cmg{
    CmgPPCallbacks::CmgPPCallbacks(SourceManager &smgr)
    :sourceManager(smgr)
    {
    }

    void CmgPPCallbacks::InclusionDirective	(
        SourceLocation 	HashLoc,
        const Token & 	IncludeTok,
        StringRef 	FileName,
        bool 	IsAngled,
        CharSourceRange 	FilenameRange,
        const FileEntry * 	File,
        StringRef 	SearchPath,
        StringRef 	RelativePath,
        const Module * 	Imported,
        SrcMgr::CharacteristicKind 	FileType 
    ){
        auto* from_file = this->sourceManager.getFileEntryForID(this->sourceManager.getFileID(HashLoc));
        auto from_name = from_file->tryGetRealPathName();
        auto to_name = File->tryGetRealPathName();
        if(
            from_name.contains("/usr/")
            ||to_name.contains("/usr/")
        ){
        }else{
            llvm::outs()<<"depends "<<from_name<<" "<<to_name<<"\n";
        }
        
    }
}